Where m is the mass of the bullet, v is the velocity of the bullet just before impact, M is the mass of the block and v is the velocity of the bullet-block system just after collision.
As the bullet-block system rises, kinetic energy is converted to potential energy.
Where g is the acceleration due to gravity and h is the displacement in height between the initial position and high point of the block.